﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YJTMedicalAideManage.Cores.PusApiModel;

namespace YJTMedicalAideManage.MAM.Model
{

    public class AssAddDto : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        private string tenant_name;
        private string live_province_id;
        private string live_city_id;
        private string live_area_id;
        private string live_province;
        private string live_city;
        private string live_area;
        private string tenant_id;
        private string name;
        private string username;
        private string tel;
        private string live_address;
        private string operator_id;
        private string password;
        private string role_id;
        private string scale;

        public string TenantName
        {
            get { return tenant_name; }
            set
            {
                if (tenant_name != value)
                {
                    tenant_name = value;
                    OnPropertyChanged(nameof(TenantName));
                }
            }
        }

        public string LiveProvinceId
        {
            get { return live_province_id; }
            set
            {
                if (live_province_id != value)
                {
                    live_province_id = value;
                    OnPropertyChanged(nameof(LiveProvinceId));
                }
            }
        }

        public string LiveProvince
        {
            get { return live_province; }
            set
            {
                if (live_province != value)
                {
                    live_province= value;
                    OnPropertyChanged(nameof(LiveProvince));
                }
            }
        }

        public string LiveCityId
        {
            get { return live_city_id; }
            set
            {
                if (live_city_id != value)
                {
                    live_city_id = value;
                    OnPropertyChanged(nameof(LiveCityId));
                }
            }
        }

        public string LiveCity
        {
            get { return live_city; }
            set
            {
                if (live_city != value)
                {
                    live_city = value;
                    OnPropertyChanged(nameof(LiveCity));
                }
            }
        }

        public string LiveAreaId
        {
            get { return live_area_id; }
            set
            {
                if (live_area_id != value)
                {
                    live_area_id = value;
                    OnPropertyChanged(nameof(LiveAreaId));
                }
            }
        }

        public string LiveArea
        {
            get { return live_area; }
            set
            {
                if (live_area != value)
                {
                    live_area = value;
                    OnPropertyChanged(nameof(LiveArea));
                }
            }
        }

        public string TenantId
        {
            get { return tenant_id; }
            set
            {
                if (tenant_id != value)
                {
                    tenant_id = value;
                    OnPropertyChanged(nameof(TenantId));
                }
            }
        }

        public string Name
        {
            get { return name; }
            set
            {
                if (name != value)
                {
                    name = value;
                    OnPropertyChanged(nameof(Name));
                }
            }
        }

        public string Username
        {
            get { return username; }
            set
            {
                if (username != value)
                {
                    username = value;
                    OnPropertyChanged(nameof(Username));
                }
            }
        }

        public string Tel
        {
            get { return tel; }
            set
            {
                if (tel != value)
                {
                    tel = value;
                    OnPropertyChanged(nameof(Tel));
                }
            }
        }

        public string LiveAddress
        {
            get { return live_address; }
            set
            {
                if (live_address != value)
                {
                    live_address = value;
                    OnPropertyChanged(nameof(LiveAddress));
                }
            }
        }

        public string OperatorId
        {
            get { return operator_id; }
            set
            {
                if (operator_id != value)
                {
                    operator_id = value;
                    OnPropertyChanged(nameof(OperatorId));
                }
            }
        }

        public string Password
        {
            get { return password; }
            set
            {
                if (password != value)
                {
                    password = value;
                    OnPropertyChanged(nameof(Password));
                }
            }
        }

        public string RoleId
        {
            get { return role_id; }
            set
            {
                if (role_id != value)
                {
                    role_id = value;
                    OnPropertyChanged(nameof(RoleId));
                }
            }
        }

        public string Scale
        {
            get { return scale; }
            set
            {
                if (scale != value)
                {
                    scale = value;
                    OnPropertyChanged(nameof(Scale));
                }
            }
        }
        private List<RegionModel> _provinces = new List<RegionModel>();
        private List<RegionModel> _cities = new List<RegionModel>();
        private List<RegionModel> _districts = new List<RegionModel>();
        public List<RegionModel> Provinces
        {
            get { return _provinces; }
            set { _provinces = value; OnPropertyChanged(nameof(Provinces)); }
        }

        public List<RegionModel> Cities
        {
            get { return _cities; }
            set { _cities = value; OnPropertyChanged(nameof(Cities)); }
        }

        public List<RegionModel> Districts
        {
            get { return _districts; }
            set { _districts = value; OnPropertyChanged(nameof(Districts)); }
        }
        public AssAddDto MapAssistantaddToAssAddDto(assistantadd assistantadd)
        {
            return new AssAddDto
            {
                TenantName = assistantadd.tenant_name,
                LiveProvinceId = assistantadd.live_province_id,
                LiveCityId = assistantadd.live_city_id,
                LiveAreaId = assistantadd.live_area_id,
                TenantId = assistantadd.tenant_id,
                Name = assistantadd.name,
                Username = assistantadd.username,
                Tel = assistantadd.tel,
                LiveAddress = assistantadd.live_address,
                OperatorId = assistantadd.operator_id,
                Password = assistantadd.password,
                RoleId = assistantadd.role_id,
                Scale = assistantadd.scale,
            };
            
        }

        public assistantadd MapAssAddDtoToAssistantadd(AssAddDto assAddDto)
        {
            return new assistantadd
            {
                tenant_name = assAddDto.TenantName,
                live_province_id = assAddDto.LiveProvinceId,
                live_city_id = assAddDto.LiveCityId,
                live_area_id = assAddDto.LiveAreaId,
                tenant_id = assAddDto.TenantId,
                name = assAddDto.Name,
                username = assAddDto.Username,
                tel = assAddDto.Tel,
                live_address = assAddDto.LiveAddress,
                operator_id = assAddDto.OperatorId,
                password = assAddDto.Password,
                role_id = assAddDto.RoleId,
                scale = assAddDto.Scale,
                live_province = assAddDto.LiveProvince,
                live_city = assAddDto.LiveCity,
                live_area = assAddDto.LiveArea
            };
        }
        protected virtual void OnPropertyChanged(string propertyName)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }
    public class AddressData
    {
        public List<RegionModel> Provinces { get; set; }
        public List<RegionModel> Cities { get; set; }
        public List<RegionModel> Districts { get; set; }
    }
    public class RegionModel
    {
        public int Id { get; set; }
        public string Name { get; set; }
    }
}
